package com.jifeng.sterilizer.controller;

import java.util.Arrays;
import java.util.Map;

import com.jifeng.sterilizer.utils.PageUtils;
import com.jifeng.sterilizer.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.jifeng.sterilizer.entity.VwControllerEntity;
import com.jifeng.sterilizer.service.VwControllerService;



/**
 * VIEW
 *
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-09-07 20:43:47
 */
@RestController
@RequestMapping("sterilizer/vmcontroller")
public class VwControllerController {
    @Autowired
    private VwControllerService vwControllerService;

    /**
     * 搜索中控器列表 PC
     */
    @GetMapping("/pc/management/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = vwControllerService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{farm}")
    public R info(@PathVariable("farm") String farm){
		VwControllerEntity vwController = vwControllerService.getById(farm);

        return R.ok().put("vwController", vwController);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody VwControllerEntity vwController){
		vwControllerService.save(vwController);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody VwControllerEntity vwController){
		vwControllerService.updateById(vwController);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody String[] farms){
		vwControllerService.removeByIds(Arrays.asList(farms));

        return R.ok();
    }

}
